using System;

#pragma warning disable 1591 // TODO CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'

namespace Fizzler.Model
{
    public class SelectorVisitor
    {
        public virtual void Accept(ISelectorGroup group)
        {
            foreach (var chain in group)
                Visit(chain);
        }

        private void Visit(ISimpleSelectorChain chain)
        {
            Visit(chain.Primary);
            foreach(var secondary in chain.Secondaries)
                Visit(secondary);
        }

        private void Visit(ISimpleSelectorChainPrimary selector)
        {
            var u = selector as IUniversalSelector;
            if (u != null)
            {
                Visit(u);
                return;
            }
            var t = selector as ITypeSelector;
            if (t != null)
            {
                Visit(t);
                return;
            }
            throw new ArgumentException(null, "selector");
        }

        private void Visit(IUniversalSelector selector)
        {
            throw new NotImplementedException();
        }

        private void Visit(ITypeSelector selector)
        {
            throw new NotImplementedException();
        }

        private void Visit(ISimpleSelectorChainSecondary selector)
        {
            var id = selector as IIdSelector;
            if (id != null)
            {
                Visit(id);
                return;
            }
            var clazz = selector as IClassSelector;
            if (clazz != null)
            {
                Visit(clazz);
                return;
            }
            var attribute = selector as IAttributeSelector;
            if (attribute != null)
            {
                Visit(attribute);
                return;
            }
            var pseudo = selector as IPseudoClassSelector;
            if (pseudo != null)
            {
                Visit(pseudo);
                return;
            }
            throw new ArgumentException(null, "selector");
        }

        private void Visit(IIdSelector selector)
        {
            throw new NotImplementedException();
        }

        private void Visit(IClassSelector selector)
        {
            throw new NotImplementedException();
        }

        private void Visit(IAttributeSelector selector)
        {
            throw new NotImplementedException();
        }

        private void Visit(IPseudoClassSelector selector)
        {
            throw new NotImplementedException();
        }
    }
}